//
//  CurveControlPointView.m
//  bezierdrawing
//
//  Created by Søren Toft on 3/21/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ControlPointView.h"

@implementation ControlPointView

- (id)initWithPosition:(CGPoint)position pointNumber:(NSInteger)number controlPoint:(CGPoint)point {
    self = [super initWithFrame:CGRectMake(0, 0, 60, 60)];
    self.center = position;
    if (self) {
        self.backgroundColor = [UIColor redColor];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,60, 60)];
        label.numberOfLines = 0;
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor blueColor];
        label.font = [UIFont boldSystemFontOfSize:15];
        label.text = [NSString stringWithFormat:@"%d\nx:%.2f\nY:%.2f", number,point.x,point.y];
        label.tag = 101;
        controlNumber = number;
        [self addSubview:label];
    }
    return self;
}

- (void)refreshPosition:(CGPoint)position
           controlPoint:(CGPoint)point
{
    self.center = position;
    UILabel *lable = (UILabel *)[self viewWithTag:101];
    lable.text = [NSString stringWithFormat:@"%d\nx:%.2f\nY:%.2f", controlNumber,point.x,point.y];
}
@end
